<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			function add(){
				let num1=document.getElementById("num1").value
				let num2=document.getElementById("num2").value
				if(isNaN(num1)||isNaN(num2)){
					document.getElementById("num3").value="只能输入数字"
					return
				}
				let num3=Number(num1)+Number(num2)
				document.getElementById("num3").value=num3.toFixed(15)-0
			}
			function sub(){
				let num1=document.getElementById("num1").value
				let num2=document.getElementById("num2").value
				if(isNaN(num1)||isNaN(num2)){
					document.getElementById("num3").value="只能输入数字"
					return
				}
				let num3=Number(num1)-Number(num2)
				document.getElementById("num3").value=num3
			}
			function mul(){
				let num1=document.getElementById("num1").value
				let num2=document.getElementById("num2").value
				if(isNaN(num1)||isNaN(num2)){
					document.getElementById("num3").value="只能输入数字"
					return
				}
				let num3=Number(num1)*Number(num2)
				document.getElementById("num3").value=num3.toFixed(15)-0
			}
			function div(){
				let num1=document.getElementById("num1").value
				let num2=document.getElementById("num2").value
				if(!isFinite(num2)){
					document.getElementById("num3").value="除数不能为0"
					return
				}
				if(isNaN(num1)||isNaN(num2)){
					document.getElementById("num3").value="只能输入数字"
					return
				}
				let num3=Number(num1)/Number(num2)
				document.getElementById("num3").value=num3
			}
		</script>
	</head>
	<body>
		第一个数：<input type="text" id="num1" /><br>
		第二个数：<input type="text" id="num2" /><br>
		<button onclick="add()">+</button>
		<button onclick="sub()">-</button>
		<button onclick="mul()">*</button>
		<button onclick="div()">/</button><br>
		计算结果：<input type="text" id="num3" /><br>
		
	</body>
</html>
